package basic;

/**
 * @author Cheng Jun
 * Description: find power of 2 >= num
 * @version 1.0
 * @date 2021/10/17 15:25
 */
public class Power2Example {

    public static void main(String[] args) {
        int num = 11;
        int power2 = 1;
        while (power2 < num)
            power2 = power2 << 1;
        System.out.println(power2);
        // 利用 Integer 的静态方法
        System.out.println(Integer.highestOneBit(11) << 1);
    }
}
